/* eslint-disable no-case-declarations */
type Sentitive<T> = T & {
    readonly '@@sentitive': unique symbol;
};

type S = { a: string } & { b: number };

const s: S = { a: '1', b: 1 };

function makeSensitive<T>(t: T): Sentitive<T> {
    return t as any as Sentitive<T>;
}

let password = makeSensitive('123');
password = '653321';

let pwd2 = '111';
pwd2 = password;

function f(x: boolean) {
    if (x) {
        return '123';
    }
    return 123;
}

type FFF = <T extends boolean>(x: T) => T extends true ? string : number;

const a = f(true);

const c: never = 1;

interface Foo {
    type: 'foo';
    name: string;
}

interface Bar {
    type: 'bar';
    age: number;
}

type All = Foo | Bar;

function handleValue(val: All) {
    switch (val.type) {
        case 'foo':
            // 明确到 Foo
            break;
        case 'bar':
            // 明确到 Bar
            break;
        default:
            // 明确到never
            const exhaustive: never = val;
            break;
    }
}

type MyMapping<T> = T extends string | number
    ? 'Deny Visit'
    : {
          [K in keyof T]: MyMapping<T[K]>;
      };
